From: Florian Müllner Date: Sun, 13 Aug 2023 22:31:16 +0000 (+0200) Subject: extensions-tool/create: Create schema template X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~320^2^2~60 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=8a01141e7de678f68b7cb1cbb65dc0bf896b5357;p=gnome-shell.git extensions-tool/create: Create schema template When creating an extension with --settings-schema, rather than just adding a corresponding entry in the metadata, generate the gschema boilerplate as well. Part-of: --- diff --git a/subprojects/extensions-tool/src/command-create.c b/subprojects/extensions-tool/src/command-create.c index 722a9f4c7..879047cb2 100644 --- a/subprojects/extensions-tool/src/command-create.c +++ b/subprojects/extensions-tool/src/command-create.c @@ -182,6 +182,42 @@ create_metadata (GFile *target_dir, error); } +static gboolean +create_settings_schema (GFile *target_dir, + const char *settings_schema, + GError **error) +{ + g_autoptr (GFile) schema_dir = NULL; + g_autoptr (GFile) schema = NULL; + g_autofree char *schema_filename = NULL; + g_autofree char *schema_path = NULL; + g_autofree char *xml = NULL; + + schema_dir = g_file_get_child (target_dir, "schemas"); + if (!g_file_make_directory (schema_dir, NULL, error)) + return FALSE; + + schema_filename = g_strdup_printf ("%s.gschema.xml", settings_schema); + schema = g_file_get_child (schema_dir, schema_filename); + + schema_path = g_strconcat ("/", settings_schema, "/", NULL); + g_strdelimit (schema_path, ".", '/'); + + xml = g_strdup_printf ("\n" + " \n" + " \n" + "\n", settings_schema, schema_path); + + return g_file_replace_contents (schema, + xml, + strlen (xml), + NULL, + FALSE, + 0, + NULL, + NULL, + error); +} static gboolean copy_extension_template (const char *template, GFile *target_dir, GError **error) @@ -272,6 +308,12 @@ create_extension (const char *uuid, return FALSE; } + if (settings_schema && !create_settings_schema (dir, settings_schema, &error)) + { + g_printerr ("%s\n", error->message); + return FALSE; + } + if (!copy_extension_template (template, dir, &error)) { g_printerr ("%s\n", error->message);